Screen Drawing Program (Part III) Ed Smith (SPACE) In this version of the Screen Drawing Program, a new option has been added to permit selecting a drawing brush. Four types of brushes are provided: a solid circle, an empty circle (no fill), a solid square and an empty square. In order to allow use of this option, a fifth box labeled "Brsh" had to be added. This 'point and click' box was done in a similar manner as the first four boxes. That is: A. Define xy locations as Xbrsh% and Ybrsh% (the 'Brsh' box). B. Insert an IF statement in the DO-LOOP that compares mousex and mousey coordinates with those of the 'Brsh' box. C. When 'Brsh' box is entered and sensed by the IF statement and the left button is pressed, the programming steps are then specified to perform the desired function. This desired function, in summary, is to provide a means for the user to select a brush style and set the size of the brush. The following procedures are performed: A. Highlight the 'Brsh' box to notify the user that the box was selected via a point and click with the mouse. See instruction: Put Xbrsh%,YBrsh%,X4$,6. B. Since a portion of the screen will be needed to interact with the user, the portion used is saved in the string Y$ by using the Get instruction. The saved screen will contain a portion of the drawing, so we want to be able to retrieve it after selecting the desired brush and size. See instruction: Get Xbr%,Ybr%,Xbr%+Wbr%,Ybr%+Hbr%,Y$. C. Replace the screen with a blank area in order to provide instructions, brushes, and 'Size' boxes for user interaction. See instruction: Put Xbr%,Ybr%,Blank$. D. Set the color and draw a fancy border around the user interactive area. See instructions: Deffill C%, Color C%, Box Xbr%,Ybr%,Xbr%+Wbr%,Ybr%+Hbr% and Box Xbr%+4,Ybr%+4,Xbr%+Wbr%-4,Ybr%+Hbr%-4. E. Now get the brush shape and size. This is described later. F. Restore the screen. See instruction: Put Xbr%,Ybr%,Y$. G. Unhighlight the 'Brsh' box. See instruction: Put Xbrsh%,Ybrsh%,X4$,6. H. Return to picture drawing mode. Referring to the Procedure Get_brush(C%), the user is asked to select a brush type and set the size of the brush. Line-by-line description follows: A. The 'Gotbrush!' flag is set to 'False'. This means that when we arrive at this routine, we haven't yet selected a brush. Later on, we will exit a DO-LOOP when the 'Got_brush!' flag is set to 'True'. B. Print user instructions. C. Plot a solid circle, empty circle, solid box and an empty box. See instructions using Pcircle, Circle, Pbox and Box. D. Establish four 'Size' boxes. See the instruction Ysize%=Ybr%+84 to set the distance from the top of the screen. The boxes are actually plotted using the FOR-NEXT loop. The horizontal x displacement is derived from the array Sx%(). This array is initially filled when plotting the upper screen. E. Print the color value and size above the drawn brush displays showing the solid and empty circles and boxes. The size number changes as the user repeatedly points and clicks on the particular 'Size' box. See instructions: I%=0, Circle2, I%=1, Circle2, I%=2, Square2, I%=3, Square2. F. The user interacts in the DO-LOOP. Within the DO-LOOP I% is constantly incremented in the range of 0 to 3 back to 0 etc. This has the effect of the computer scanning all four 'Size' boxes, looking for a user interaction in the form of a point and click. When the IF statement confirms a user point and click action with the left mouse button pressed, the size value S% or R% is incremented in the range of 1 to 14 and back to 1 etc. S% controlls the size of the squares and R% controls the radius of the circles. If the 'point and click' action is the pressing of the right mouse button, the 'Gotbrush!' flag is set to 'True'. The Exit instruction senses the 'Gotbrush!' flag and returns to user draw mode. I hope this program will help those who are learning GFA Basic. Happy Programming in GFA. [Ed. Note: The type in GFA Basic source for this program appears below, but is also contained on the October 1990 ST/Mega Disk of the Month, along with the compiled version of this program.]